/*
 * YuebaoBuffer.h
 *
 *  Created on: 2011-3-19
 *      Author: wangchao
 */

#ifndef YUEBAOBUFFER8_H_
#define YUEBAOBUFFER8_H_
#include <e32cmn.h>

class YuebaoBufferBase8
{
public:
    YuebaoBufferBase8( int length );
    virtual ~YuebaoBufferBase8( );
protected:
    int _bufferLength;
    HBufC8* _bufferPtr;
public:

    void SetMaxLength( int length );
public:
    HBufC8* Buffer( );
    const TDesC8& operator()( );
    TPtr8 Des( );

    int Length( );
    void Zero( );

    void Copy( const TDesC8& aDes );
    void Copy( const TDesC16& aDes );

    void Append( TChar ch );
    void Append( const TDesC8 &aDes );
    void Append( const TDesC &aDes );
    void AppendNum( TInt64 number );

    int Compare( const TDesC8& aDes );

    int Find( const TDesC8& aDes );
    int Locate( TChar ch );
    int LocateReverse( TChar ch );

    TPtrC8 Left( int length );
    TPtrC8 Right( int length );
    TPtrC8 Mid( int pos );
    TPtrC8 Mid( int pos, int length );

    void Format( TRefByValue< const TDesC8 > aFmt, ... );
};

template< int S >
class YuebaoBuffer8 : public YuebaoBufferBase8
{
public:
    YuebaoBuffer8( ) :
        YuebaoBufferBase8( S )
    {

    }
public:
    YuebaoBuffer8& operator=( const TDesC8 &aDes )
    {
        Copy( aDes );
        return *this;
    }
};

#endif /* YUEBAOBUFFER_H_ */
